import Vue from 'vue'
//导入路由
import VueRouter from 'vue-router';
import Index from '@/pages/Index'
import Search from '@/pages/Search'
import AddBlog from '@/pages/AddBlog'
import MyBlog from '@/pages/MyBlog'

//注册路由

Vue.use(VueRouter)

const router = new VueRouter({
  mode:'history',
  routes:[
    {
      path:'/',
      name:'home',
      component:Index
    },
    {
      path:'/search',
      name:'search',
      component:Search
    },
    {
        path:'/add',
        name:'addBlog',
        component:AddBlog
      },
    {
      path:'/my',
      name:'myBlog',
      component:MyBlog
    },
   
  ] 
}) 
router.beforeEach((to,from,next)=>{
  //前置守卫,路由守卫
  next();
})

export default router